import wx
from wx.lib.pubsub import setuparg1
from wx.lib.pubsub import pub


from ViewTodoList import ViewTodoList
from SimplePanels import PanelTodo
from ViewTodoCalendar import ViewTodoCalendar

class ViewTodo(wx.Panel):

    """
    this class deal with todo view, there are 2 subviews in this view:
    canlendar and list
    """
    def __init__(self, parent):
        wx.Panel.__init__(self, parent = parent)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.v1 = ViewTodoList(self)
        self.v2 = ViewTodoCalendar(self)
        self.v2.Hide()
        self.sizer.Add(self.v1, 1, wx.EXPAND|wx.ALL)
        self.sizer.Add(self.v2, 1, wx.EXPAND|wx.ALL)

        self.SetSizer(self.sizer)
        pub.subscribe(self.toggle_view, PanelTodo.M_TODO_TOGGLE_VIEW)
        self.view_mode = 0

    def toggle_view(self, m):
        #change main view when toggle view button is pressed
        #haha, this is clever !
        self.view_mode = not self.view_mode
        if self.view_mode == 0:
            self.v2.Hide()
            self.v1.Show()
            self.sizer.Layout()
        else:
            self.v1.Hide()
            self.v2.Show()
            self.sizer.Layout()
